package com.atguigu.java.ai.langchain4j.config;

import com.atguigu.java.ai.langchain4j.store.MongoChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:Simple
 * @Date: 2025/8/29 18:49
 * @Description:
 **/
@Configuration
public class ChatConfigStoreConfig {
    @Autowired
    MongoChatMemoryStore mongoChatMemoryStore;
    /**
     * @author: Simple
     * @date: 2025-08-29 19:05:33
     * @description: 回话隔离 记忆 log记录 删除 更新
     */
    @Bean
    public ChatMemoryProvider chatConfigStore(){
        return  memoryId->MessageWindowChatMemory.builder()
                .maxMessages(10)
                .id(memoryId)
                .chatMemoryStore(mongoChatMemoryStore)
                .build();
    }
}
